const { Service } = require('egg');

class BeerRecordService extends Service {
  async list() {
    const results = await this.app.mysql.select('user', {});

    return results;
  }

  async detail({ id, open_id }) {
    const params = {};
    if (id) params.id = id;
    if (open_id) params.open_id = open_id;
    const results = await this.app.mysql.select('user', {
      where: params,
    });

    return results?.[0] || null;
  }

  async add(data) {
    const results = await this.app.mysql.insert('user', data);

    return results;
  }
}

module.exports = BeerRecordService;
